<?php
session_start();
if ($_SESSION['auth'] != true && $_SESSION['rule'] != "ADMIN") {
	die('Not log in');
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Admin</title>
<link href="itelement.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="script/jquery.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
var is_collapsed = false;
function deleteChannel(cid)
{
	$('#status').show();
	$('#status').text('Wait server...');
	$.post("admin_operation.php?action=delete_channel", "id="+cid,
	  function(data){
		$('#status').text(data);
	  });
}
</script>
</head>
<body>
	  <div class="viewer-head">
		<div class="viewer-head-left">Search Channel</div>
		<!--<div class="viewer-head-right"><input type="button" value="reset"></div>-->
	  </div>
	  <table bgcolor="#f1f8ff">
	  <tr bgcolor="#d0e3f1" class="table-header">
		<td width="50%">Title</td>
		<td width="10%">Link</td>
		<td width="10%">Rank</td>
		<td width="1">&nbsp;</td>
	  </tr>
	  <?php
	  include("includes/adminController.php");
	  
	  $channels = searchChannel(null,$_GET['title'],$_GET['link'],null,null,null,null,null,null
					,null,null,null,$_GET['rank']);
	  foreach($channels as $c)
	  {
	  if($c == '')continue;
	  echo "<tr><td><a href=\"admin_edit_channel.php?id=".$c['id']."\">".$c['title']."</a></td>";
	  echo "<td><a href=\"".$c['docs']."\" target=\"_blank\">".$c['docs']."</a></td>";
	  echo "<td>".$c['rank']."</td>";
	  echo "<td><input type='button' onclick='deleteChannel(".$c['id'].")' value='delete'></td>";
	  echo "</tr>";
	  }
	  ?>
	  </table>
	  <div id="status"></div>
</body>
</html>